package com.qf.serviceimpl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.qf.mapper.DtsGoodsAttributeMapper;
import com.qf.pojo.DtsGoodsAttribute;
import com.qf.service.DtsGoodsAttributeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * @author Ypl
 * @version V1.0
 * @Project September-mavens
 * @Package com.qf.serviceimpl
 * @Description:
 * @Date 2022/10/17 22:22
 */
@Service
public class DtsGoodsAttributeServiceImpl implements DtsGoodsAttributeService {

    @Autowired
    DtsGoodsAttributeMapper dtsGoodsAttributeMapper;

    @Override
    public void insert(DtsGoodsAttribute attribute) {
        attribute.setAddTime(new Date());
        attribute.setUpdateTime(new Date());
        attribute.setDeleted(false);

        dtsGoodsAttributeMapper.insert(attribute);
    }

    @Override
    public List<DtsGoodsAttribute> findByGoodsId(Integer goodsId) {
        LambdaQueryWrapper<DtsGoodsAttribute> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(DtsGoodsAttribute::getGoodsId,goodsId);
        wrapper.eq(DtsGoodsAttribute::getDeleted,false);

        return dtsGoodsAttributeMapper.selectList(wrapper);
    }

    @Override
    public void delete(Integer id) {
        dtsGoodsAttributeMapper.deleteById(id);
    }
}
